package com.benmei.weike.dto.mcCourse;

import com.benmei.weike.common.Constants;
import com.benmei.weike.util.CommonUtil;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by Peter on 2018/10/9.
 */
public class McCourseDetailResponse {
    private Integer id;
    private String title;
    private String cover_large_url;// 封面图片，小图
    private Date course_start_time;// 上课时间
    private Date course_end_time;
    private Integer cou_size;//课时数
    private Integer max_buy_user_number;// 限购人数
    private Integer actual_buy_user_number;//实际购买人数
    private Date appointment_start_time;//预售时间
    private Date appointment_end_time;
    private Date sale_start_time;//开售时间
    private Date sale_end_time;
    private Date server_current_time;// 服务器系统当前时间

    // 拼单(团购)
    private Integer group_user_number;// 拼单人数
    private List<McCourseGroupDto> groups = new ArrayList<>();

    private String detail_image_url;// 课程介绍图片url
    private String detail_image_html;// 课程介绍html
    private String teacher_intro_image_url;//老师介绍图片地址
    private String teacher_intro_image_html;//老师介绍html

    private BigDecimal price;// 价格
    private BigDecimal group_price;// 团购价格
    private Integer sale_state;    // 销售状态：0 未开始销售；1 预售；2 开始销售（限售）；3 售完
    private Integer buy_state = 0; // 购买状态状态：0 未预定，未购买；1 已预订；2 已购；3 拼团购买
    private String my_group_detail_url;// 拼团详情页url
    private Integer enable_group = 0;// 该课程是否可以团购（1：可以团购， 0：不可以团购）
    private Integer group_max_user;//1个团的最大人数上限
    private String group_agreement_url;//拼团说明页面url
    private String group_result_url;// 团购结果页面

    private Integer comment_size;// 评价数量

    // 分享需要的参数
    private String share_url;
    private String share_title;
    private String share_desc;

    private List<McCourseScheduleDto> course_schedule = new ArrayList<>();// 课表
    private List<McCourseCommentDto> course_comments = new ArrayList<>();// 评论

    public String getShare_url() {
        return share_url;
    }

    public void setShare_url(String share_url) {
        this.share_url = share_url;
    }

    public String getShare_title() {
        return share_title;
    }

    public void setShare_title(String share_title) {
        this.share_title = share_title;
    }

    public String getShare_desc() {
        return share_desc;
    }

    public void setShare_desc(String share_desc) {
        this.share_desc = share_desc;
    }

    public String getDetail_image_html() {
        return detail_image_html;
    }

    public void setDetail_image_html(String detail_image_html) {
        this.detail_image_html = detail_image_html;
    }

    public String getTeacher_intro_image_html() {
        return teacher_intro_image_html;
    }

    public void setTeacher_intro_image_html(String teacher_intro_image_html) {
        this.teacher_intro_image_html = teacher_intro_image_html;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getCover_large_url() {
        return CommonUtil.getFullUri(cover_large_url);
    }

    public void setCover_large_url(String cover_large_url) {
        this.cover_large_url = cover_large_url;
    }

    public Date getCourse_start_time() {
        return course_start_time;
    }

    public void setCourse_start_time(Date course_start_time) {
        this.course_start_time = course_start_time;
    }

    public Date getCourse_end_time() {
        return course_end_time;
    }

    public void setCourse_end_time(Date course_end_time) {
        this.course_end_time = course_end_time;
    }

    public Integer getCou_size() {
        return cou_size;
    }

    public void setCou_size(Integer cou_size) {
        this.cou_size = cou_size;
    }

    public Integer getMax_buy_user_number() {
        return max_buy_user_number;
    }

    public void setMax_buy_user_number(Integer max_buy_user_number) {
        this.max_buy_user_number = max_buy_user_number;
    }

    public Integer getActual_buy_user_number() {
        return actual_buy_user_number;
    }

    public void setActual_buy_user_number(Integer actual_buy_user_number) {
        this.actual_buy_user_number = actual_buy_user_number;
    }

    public Date getAppointment_start_time() {
        return appointment_start_time;
    }

    public void setAppointment_start_time(Date appointment_start_time) {
        this.appointment_start_time = appointment_start_time;
    }

    public Date getAppointment_end_time() {
        return appointment_end_time;
    }

    public void setAppointment_end_time(Date appointment_end_time) {
        this.appointment_end_time = appointment_end_time;
    }

    public Date getSale_start_time() {
        return sale_start_time;
    }

    public void setSale_start_time(Date sale_start_time) {
        this.sale_start_time = sale_start_time;
    }

    public Date getSale_end_time() {
        return sale_end_time;
    }

    public void setSale_end_time(Date sale_end_time) {
        this.sale_end_time = sale_end_time;
    }

    public Integer getGroup_user_number() {
        return group_user_number;
    }

    public void setGroup_user_number(Integer group_user_number) {
        this.group_user_number = group_user_number;
    }

    public List<McCourseGroupDto> getGroups() {
        return groups;
    }

    public void setGroups(List<McCourseGroupDto> groups) {
        this.groups = groups;
    }

    public String getDetail_image_url() {
        return detail_image_url;
    }

    public void setDetail_image_url(String detail_image_url) {
        this.detail_image_url = detail_image_url;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public BigDecimal getGroup_price() {
        return group_price;
    }

    public void setGroup_price(BigDecimal group_price) {
        this.group_price = group_price;
    }

    public Integer getSale_state() {
        Long currentTime = System.currentTimeMillis();
        if (currentTime < this.appointment_start_time.getTime()) {
            sale_state = Constants.McCourse.SaleState.unStart;
        } else if (currentTime >= this.appointment_start_time.getTime() && currentTime <= this.appointment_end_time.getTime()) {
            sale_state = Constants.McCourse.SaleState.preSale;
        } else if (currentTime >= this.sale_start_time.getTime() && currentTime <= this.sale_end_time.getTime() && this.actual_buy_user_number >= this.max_buy_user_number) {
            sale_state = Constants.McCourse.SaleState.saleOver;
        } else if (currentTime > this.sale_end_time.getTime()) {
            sale_state = Constants.McCourse.SaleState.saleOver;
        } else {
            sale_state = Constants.McCourse.SaleState.sale;
        }
        return sale_state;
    }

    public void setSale_state(Integer sale_state) {
        this.sale_state = sale_state;
    }

    public Date getServer_current_time() {
        return server_current_time;
    }

    public void setServer_current_time(Date server_current_time) {
        this.server_current_time = server_current_time;
    }

    public Integer getBuy_state() {
        return buy_state;
    }

    public void setBuy_state(Integer buy_state) {
        this.buy_state = buy_state;
    }

    public String getMy_group_detail_url() {
        return my_group_detail_url;
    }

    public void setMy_group_detail_url(String my_group_detail_url) {
        this.my_group_detail_url = my_group_detail_url;
    }

    public String getTeacher_intro_image_url() {
        return teacher_intro_image_url;
    }

    public void setTeacher_intro_image_url(String teacher_intro_image_url) {
        this.teacher_intro_image_url = teacher_intro_image_url;
    }

    public Integer getComment_size() {
        return comment_size;
    }

    public void setComment_size(Integer comment_size) {
        this.comment_size = comment_size;
    }

    public Integer getEnable_group() {
        return enable_group;
    }

    public void setEnable_group(Integer enable_group) {
        this.enable_group = enable_group;
    }

    public Integer getGroup_max_user() {
        return group_max_user;
    }

    public void setGroup_max_user(Integer group_max_user) {
        this.group_max_user = group_max_user;
    }

    public String getGroup_agreement_url() {
        return group_agreement_url;
    }

    public void setGroup_agreement_url(String group_agreement_url) {
        this.group_agreement_url = group_agreement_url;
    }

    public String getGroup_result_url() {
        return group_result_url;
    }

    public void setGroup_result_url(String group_result_url) {
        this.group_result_url = group_result_url;
    }

    public List<McCourseScheduleDto> getCourse_schedule() {
        return course_schedule;
    }

    public void setCourse_schedule(List<McCourseScheduleDto> course_schedule) {
        this.course_schedule = course_schedule;
    }

    public List<McCourseCommentDto> getCourse_comments() {
        return course_comments;
    }

    public void setCourse_comments(List<McCourseCommentDto> course_comments) {
        this.course_comments = course_comments;
    }
}
